home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume22 / pty / part06 < prev    next >
Encoding:
Internet Message Format  |  1990-10-09  |  13.8 KB

  1. Subject:  v23i036:  Run a program under a pty session, Part06/06
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: e1cac7b9 4b5d3634 52ea5782 fd74f891
  5.  
  6. Submitted-by: Dan Bernstein <brnstnd@kramden.acf.nyu.edu>
  7. Posting-number: Volume 23, Issue 36
  8. Archive-name: pty/part06
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then feed it
  12. # into a shell via "sh file" or similar.  To overwrite existing files,
  13. # type "sh file -c".
  14. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  15. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  16. # Contents:  err.h file.h file.h.new getopt.h logs.h master.h misc.h
  17. #   patch/TELNET.FTP sigler.h slave.h texts.h util/condom
  18. #   util/excloff.1 util/excloff.c util/exclon.c util/script
  19. #   util/script.tidy util/sess util/tiocsti.1 util/tiocsti.c
  20. #   util/tty.1 util/tty.c
  21. # Wrapped by rsalz@litchi.bbn.com on Wed Oct 10 10:11:43 1990
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 6 (of 6)."'
  25. if test -f 'err.h' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'err.h'\"
  27. else
  28.   echo shar: Extracting \"'err.h'\" \(385 characters\)
  29.   sed "s/^X//" >'err.h' <<'END_OF_FILE'
  30. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  31. X
  32. X#ifndef PTY_ERR_H
  33. X#define PTY_ERR_H
  34. X
  35. X#include <errno.h>
  36. Xextern int errno; /* not always defined in errno.h, grrrr */
  37. Xextern int sys_nerr;
  38. Xextern char *sys_errlist[];
  39. X
  40. Xextern void fatal();
  41. Xextern void fatalinfo();
  42. Xextern void fatalerr();
  43. Xextern void fatalerr2p();
  44. Xextern void fatalerrp();
  45. Xextern void warnerr2();
  46. X
  47. X#endif
  48. END_OF_FILE
  49.   if test 385 -ne `wc -c <'err.h'`; then
  50.     echo shar: \"'err.h'\" unpacked with wrong size!
  51.   fi
  52.   # end of 'err.h'
  53. fi
  54. if test -f 'file.h' -a "${1}" != "-c" ; then 
  55.   echo shar: Will not clobber existing file \"'file.h'\"
  56. else
  57.   echo shar: Extracting \"'file.h'\" \(224 characters\)
  58.   sed "s/^X//" >'file.h' <<'END_OF_FILE'
  59. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  60. X
  61. X#ifndef PTY_FILE_H
  62. X#define PTY_FILE_H
  63. X
  64. X#include <sys/file.h>
  65. X#ifdef BSD
  66. X#include <limits.h>
  67. X#endif
  68. X#include <fcntl.h>
  69. Xextern long lseek(); /* sigh. */
  70. X
  71. X#endif
  72. END_OF_FILE
  73.   if test 224 -ne `wc -c <'file.h'`; then
  74.     echo shar: \"'file.h'\" unpacked with wrong size!
  75.   fi
  76.   # end of 'file.h'
  77. fi
  78. if test -f 'file.h.new' -a "${1}" != "-c" ; then 
  79.   echo shar: Will not clobber existing file \"'file.h.new'\"
  80. else
  81.   echo shar: Extracting \"'file.h.new'\" \(224 characters\)
  82.   sed "s/^X//" >'file.h.new' <<'END_OF_FILE'
  83. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  84. X
  85. X#ifndef PTY_FILE_H
  86. X#define PTY_FILE_H
  87. X
  88. X#include <sys/file.h>
  89. X#ifdef BSD
  90. X#include <limits.h>
  91. X#endif
  92. X#include <fcntl.h>
  93. Xextern long lseek(); /* sigh. */
  94. X
  95. X#endif
  96. END_OF_FILE
  97.   if test 224 -ne `wc -c <'file.h.new'`; then
  98.     echo shar: \"'file.h.new'\" unpacked with wrong size!
  99.   fi
  100.   # end of 'file.h.new'
  101. fi
  102. if test -f 'getopt.h' -a "${1}" != "-c" ; then 
  103.   echo shar: Will not clobber existing file \"'getopt.h'\"
  104. else
  105.   echo shar: Extracting \"'getopt.h'\" \(250 characters\)
  106.   sed "s/^X//" >'getopt.h' <<'END_OF_FILE'
  107. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  108. X
  109. X#ifndef PTY_GETOPT_H
  110. X#define PTY_GETOPT_H
  111. X
  112. X/* The following should be in /usr/include/getopt.h but often aren't. */
  113. Xextern int getopt();
  114. Xextern char *optarg;
  115. Xextern int optind;
  116. X
  117. X#endif
  118. END_OF_FILE
  119.   if test 250 -ne `wc -c <'getopt.h'`; then
  120.     echo shar: \"'getopt.h'\" unpacked with wrong size!
  121.   fi
  122.   # end of 'getopt.h'
  123. fi
  124. if test -f 'logs.h' -a "${1}" != "-c" ; then 
  125.   echo shar: Will not clobber existing file \"'logs.h'\"
  126. else
  127.   echo shar: Extracting \"'logs.h'\" \(169 characters\)
  128.   sed "s/^X//" >'logs.h' <<'END_OF_FILE'
  129. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  130. X
  131. X#ifndef PTY_LOGS_H
  132. X#define PTY_LOGS_H
  133. X
  134. Xextern long now();
  135. Xextern int utmp();
  136. Xextern int wtmp();
  137. X
  138. X#endif
  139. END_OF_FILE
  140.   if test 169 -ne `wc -c <'logs.h'`; then
  141.     echo shar: \"'logs.h'\" unpacked with wrong size!
  142.   fi
  143.   # end of 'logs.h'
  144. fi
  145. if test -f 'master.h' -a "${1}" != "-c" ; then 
  146.   echo shar: Will not clobber existing file \"'master.h'\"
  147. else
  148.   echo shar: Extracting \"'master.h'\" \(138 characters\)
  149.   sed "s/^X//" >'master.h' <<'END_OF_FILE'
  150. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  151. X
  152. X#ifndef PTY_MASTER_H
  153. X#define PTY_MASTER_H
  154. X
  155. Xextern void master();
  156. X
  157. X#endif
  158. END_OF_FILE
  159.   if test 138 -ne `wc -c <'master.h'`; then
  160.     echo shar: \"'master.h'\" unpacked with wrong size!
  161.   fi
  162.   # end of 'master.h'
  163. fi
  164. if test -f 'misc.h' -a "${1}" != "-c" ; then 
  165.   echo shar: Will not clobber existing file \"'misc.h'\"
  166. else
  167.   echo shar: Extracting \"'misc.h'\" \(190 characters\)
  168.   sed "s/^X//" >'misc.h' <<'END_OF_FILE'
  169. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  170. X
  171. X#ifndef PTY_MISC_H
  172. X#define PTY_MISC_H
  173. X
  174. Xextern int sessdir();
  175. Xextern char *real_ttyname();
  176. Xextern void setusername();
  177. X
  178. X#endif
  179. END_OF_FILE
  180.   if test 190 -ne `wc -c <'misc.h'`; then
  181.     echo shar: \"'misc.h'\" unpacked with wrong size!
  182.   fi
  183.   # end of 'misc.h'
  184. fi
  185. if test -f 'patch/TELNET.FTP' -a "${1}" != "-c" ; then 
  186.   echo shar: Will not clobber existing file \"'patch/TELNET.FTP'\"
  187. else
  188.   echo shar: Extracting \"'patch/TELNET.FTP'\" \(69 characters\)
  189.   sed "s/^X//" >'patch/TELNET.FTP' <<'END_OF_FILE'
  190. Xuser anonymous pty
  191. Xcd pub
  192. Xtype binary
  193. Xget telnet.90.06.28.tar.Z
  194. Xquit
  195. END_OF_FILE
  196.   if test 69 -ne `wc -c <'patch/TELNET.FTP'`; then
  197.     echo shar: \"'patch/TELNET.FTP'\" unpacked with wrong size!
  198.   fi
  199.   # end of 'patch/TELNET.FTP'
  200. fi
  201. if test -f 'sigler.h' -a "${1}" != "-c" ; then 
  202.   echo shar: Will not clobber existing file \"'sigler.h'\"
  203. else
  204.   echo shar: Extracting \"'sigler.h'\" \(138 characters\)
  205.   sed "s/^X//" >'sigler.h' <<'END_OF_FILE'
  206. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  207. X
  208. X#ifndef PTY_SIGLER_H
  209. X#define PTY_SIGLER_H
  210. X
  211. Xextern void sigler();
  212. X
  213. X#endif
  214. END_OF_FILE
  215.   if test 138 -ne `wc -c <'sigler.h'`; then
  216.     echo shar: \"'sigler.h'\" unpacked with wrong size!
  217.   fi
  218.   # end of 'sigler.h'
  219. fi
  220. if test -f 'slave.h' -a "${1}" != "-c" ; then 
  221.   echo shar: Will not clobber existing file \"'slave.h'\"
  222. else
  223.   echo shar: Extracting \"'slave.h'\" \(135 characters\)
  224.   sed "s/^X//" >'slave.h' <<'END_OF_FILE'
  225. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  226. X
  227. X#ifndef PTY_SLAVE_H
  228. X#define PTY_SLAVE_H
  229. X
  230. Xextern void slave();
  231. X
  232. X#endif
  233. END_OF_FILE
  234.   if test 135 -ne `wc -c <'slave.h'`; then
  235.     echo shar: \"'slave.h'\" unpacked with wrong size!
  236.   fi
  237.   # end of 'slave.h'
  238. fi
  239. if test -f 'texts.h' -a "${1}" != "-c" ; then 
  240.   echo shar: Will not clobber existing file \"'texts.h'\"
  241. else
  242.   echo shar: Extracting \"'texts.h'\" \(273 characters\)
  243.   sed "s/^X//" >'texts.h' <<'END_OF_FILE'
  244. X/* Copyright 1990, Daniel J. Bernstein. All rights reserved. */
  245. X
  246. X#ifndef PTY_TEXTS_H
  247. X#define PTY_TEXTS_H
  248. X
  249. Xextern char *ptyauthor[];
  250. Xextern char *ptyversion[];
  251. Xextern char *ptycopyright[];
  252. Xextern char *ptywarranty[];
  253. Xextern char *ptyusage[];
  254. Xextern char *ptyhelp[];
  255. X
  256. X#endif
  257. END_OF_FILE
  258.   if test 273 -ne `wc -c <'texts.h'`; then
  259.     echo shar: \"'texts.h'\" unpacked with wrong size!
  260.   fi
  261.   # end of 'texts.h'
  262. fi
  263. if test -f 'util/condom' -a "${1}" != "-c" ; then 
  264.   echo shar: Will not clobber existing file \"'util/condom'\"
  265. else
  266.   echo shar: Extracting \"'util/condom'\" \(44 characters\)
  267.   sed "s/^X//" >'util/condom' <<'END_OF_FILE'
  268. X#!/bin/sh
  269. X# Public domain.
  270. Xexec pty -0 "$@"
  271. END_OF_FILE
  272.   if test 44 -ne `wc -c <'util/condom'`; then
  273.     echo shar: \"'util/condom'\" unpacked with wrong size!
  274.   fi
  275.   chmod +x 'util/condom'
  276.   # end of 'util/condom'
  277. fi
  278. if test -f 'util/excloff.1' -a "${1}" != "-c" ; then 
  279.   echo shar: Will not clobber existing file \"'util/excloff.1'\"
  280. else
  281.   echo shar: Extracting \"'util/excloff.1'\" \(18 characters\)
  282.   sed "s/^X//" >'util/excloff.1' <<'END_OF_FILE'
  283. X.so man1/exclon.1
  284. END_OF_FILE
  285.   if test 18 -ne `wc -c <'util/excloff.1'`; then
  286.     echo shar: \"'util/excloff.1'\" unpacked with wrong size!
  287.   fi
  288.   # end of 'util/excloff.1'
  289. fi
  290. if test -f 'util/excloff.c' -a "${1}" != "-c" ; then 
  291.   echo shar: Will not clobber existing file \"'util/excloff.c'\"
  292. else
  293.   echo shar: Extracting \"'util/excloff.c'\" \(110 characters\)
  294.   sed "s/^X//" >'util/excloff.c' <<'END_OF_FILE'
  295. X/* Public domain. */
  296. X#include <sys/ioctl.h>
  297. X
  298. Xmain()
  299. X{
  300. X (void) ioctl(1,(unsigned long) TIOCNXCL,(char *) 0);
  301. X}
  302. END_OF_FILE
  303.   if test 110 -ne `wc -c <'util/excloff.c'`; then
  304.     echo shar: \"'util/excloff.c'\" unpacked with wrong size!
  305.   fi
  306.   # end of 'util/excloff.c'
  307. fi
  308. if test -f 'util/exclon.c' -a "${1}" != "-c" ; then 
  309.   echo shar: Will not clobber existing file \"'util/exclon.c'\"
  310. else
  311.   echo shar: Extracting \"'util/exclon.c'\" \(110 characters\)
  312.   sed "s/^X//" >'util/exclon.c' <<'END_OF_FILE'
  313. X/* Public domain. */
  314. X#include <sys/ioctl.h>
  315. X
  316. Xmain()
  317. X{
  318. X (void) ioctl(1,(unsigned long) TIOCEXCL,(char *) 0);
  319. X}
  320. END_OF_FILE
  321.   if test 110 -ne `wc -c <'util/exclon.c'`; then
  322.     echo shar: \"'util/exclon.c'\" unpacked with wrong size!
  323.   fi
  324.   # end of 'util/exclon.c'
  325. fi
  326. if test -f 'util/script' -a "${1}" != "-c" ; then 
  327.   echo shar: Will not clobber existing file \"'util/script'\"
  328. else
  329.   echo shar: Extracting \"'util/script'\" \(299 characters\)
  330.   sed "s/^X//" >'util/script' <<'END_OF_FILE'
  331. X#!/bin/sh
  332. X# Public domain.
  333. Xcase "$@" in
  334. X"") extra=typescript ;;
  335. X"-a") extra=typescript ;;
  336. X"-i") extra=typescript ;;
  337. X"-a -i") extra=typescript ;;
  338. Xesac
  339. Xecho "Script started, teeing $@" "$extra"
  340. X( echo 'Script started on '`date`;
  341. X  pty -s "$SHELL";
  342. X  echo 'Script done on '`date` ) | tee "$@" "$extra"
  343. END_OF_FILE
  344.   if test 299 -ne `wc -c <'util/script'`; then
  345.     echo shar: \"'util/script'\" unpacked with wrong size!
  346.   fi
  347.   chmod +x 'util/script'
  348.   # end of 'util/script'
  349. fi
  350. if test -f 'util/script.tidy' -a "${1}" != "-c" ; then 
  351.   echo shar: Will not clobber existing file \"'util/script.tidy'\"
  352. else
  353.   echo shar: Extracting \"'util/script.tidy'\" \(63 characters\)
  354.   sed "s/^X//" >'util/script.tidy' <<'END_OF_FILE'
  355. X#!/bin/sh
  356. X# Public domain.
  357. Xexec sed -e 's/$//' -e 's/[^]//g'
  358. END_OF_FILE
  359.   echo shar: 2 control characters may be missing from \"'util/script.tidy'\"
  360.   if test 63 -ne `wc -c <'util/script.tidy'`; then
  361.     echo shar: \"'util/script.tidy'\" unpacked with wrong size!
  362.   fi
  363.   chmod +x 'util/script.tidy'
  364.   # end of 'util/script.tidy'
  365. fi
  366. if test -f 'util/sess' -a "${1}" != "-c" ; then 
  367.   echo shar: Will not clobber existing file \"'util/sess'\"
  368. else
  369.   echo shar: Extracting \"'util/sess'\" \(44 characters\)
  370.   sed "s/^X//" >'util/sess' <<'END_OF_FILE'
  371. X#!/bin/sh
  372. X# Public domain.
  373. Xexec pty -s "$@"
  374. END_OF_FILE
  375.   if test 44 -ne `wc -c <'util/sess'`; then
  376.     echo shar: \"'util/sess'\" unpacked with wrong size!
  377.   fi
  378.   chmod +x 'util/sess'
  379.   # end of 'util/sess'
  380. fi
  381. if test -f 'util/tiocsti.1' -a "${1}" != "-c" ; then 
  382.   echo shar: Will not clobber existing file \"'util/tiocsti.1'\"
  383. else
  384.   echo shar: Extracting \"'util/tiocsti.1'\" \(250 characters\)
  385.   sed "s/^X//" >'util/tiocsti.1' <<'END_OF_FILE'
  386. X.TH tiocsti 1
  387. X.SH NAME
  388. Xtiocsti \- simulate terminal input
  389. X.SH SYNOPSIS
  390. X.B tiocsti
  391. X[
  392. X.I arg
  393. X] ...
  394. X.SH DESCRIPTION
  395. X.I tiocsti
  396. X``types'' each of its arguments on the
  397. Xcurrent terminal, separated by spaces,
  398. Xas if you had typed them.
  399. X.SH "SEE ALSO"
  400. Xtty(4)
  401. END_OF_FILE
  402.   if test 250 -ne `wc -c <'util/tiocsti.1'`; then
  403.     echo shar: \"'util/tiocsti.1'\" unpacked with wrong size!
  404.   fi
  405.   # end of 'util/tiocsti.1'
  406. fi
  407. if test -f 'util/tiocsti.c' -a "${1}" != "-c" ; then 
  408.   echo shar: Will not clobber existing file \"'util/tiocsti.c'\"
  409. else
  410.   echo shar: Extracting \"'util/tiocsti.c'\" \(322 characters\)
  411.   sed "s/^X//" >'util/tiocsti.c' <<'END_OF_FILE'
  412. X/* Public domain. */
  413. X#include <sys/ioctl.h>
  414. X
  415. Xmain(argc,argv)
  416. Xint argc;
  417. Xchar *argv[];
  418. X{
  419. X int j;
  420. X char *s;
  421. X
  422. X if (ioctl(3,TIOCGPGRP,(char *) &j) == -1)
  423. X   (void) dup2(0,3);
  424. X
  425. X for (j = 1;j < argc;j++)
  426. X  {
  427. X   for (s = argv[j];*s;s++)
  428. X     (void) ioctl(3,TIOCSTI,s);
  429. X   if (j < argc - 1)
  430. X     (void) ioctl(3,TIOCSTI," ");
  431. X  }
  432. X}
  433. END_OF_FILE
  434.   if test 322 -ne `wc -c <'util/tiocsti.c'`; then
  435.     echo shar: \"'util/tiocsti.c'\" unpacked with wrong size!
  436.   fi
  437.   # end of 'util/tiocsti.c'
  438. fi
  439. if test -f 'util/tty.1' -a "${1}" != "-c" ; then 
  440.   echo shar: Will not clobber existing file \"'util/tty.1'\"
  441. else
  442.   echo shar: Extracting \"'util/tty.1'\" \(279 characters\)
  443.   sed "s/^X//" >'util/tty.1' <<'END_OF_FILE'
  444. X.TH tty 1
  445. X.SH NAME
  446. Xtty \- get terminal name
  447. X.SH SYNOPSIS
  448. X.B tty
  449. X[
  450. X.B\-s
  451. X]
  452. X.SH DESCRIPTION
  453. X.I tty
  454. Xprints the pathname of the user's terminal,
  455. Xor
  456. X``not a tty''
  457. Xif its input is not a terminal.
  458. X.I tty \-s
  459. Xprints nothing.
  460. X.SH "EXIT VALUE"
  461. X0 if the input is a terminal,
  462. X1 if it isn't.
  463. END_OF_FILE
  464.   if test 279 -ne `wc -c <'util/tty.1'`; then
  465.     echo shar: \"'util/tty.1'\" unpacked with wrong size!
  466.   fi
  467.   # end of 'util/tty.1'
  468. fi
  469. if test -f 'util/tty.c' -a "${1}" != "-c" ; then 
  470.   echo shar: Will not clobber existing file \"'util/tty.c'\"
  471. else
  472.   echo shar: Extracting \"'util/tty.c'\" \(298 characters\)
  473.   sed "s/^X//" >'util/tty.c' <<'END_OF_FILE'
  474. X/* Public domain. */
  475. X
  476. Xextern char *ttyname();
  477. X
  478. Xmain(argc,argv)
  479. Xint argc;
  480. Xchar *argv[];
  481. X{
  482. X char *s;
  483. X
  484. X s = ttyname(0);
  485. X
  486. X if ((argc != 2)
  487. X   ||(argv[1][0] != '-') || (argv[1][1] != 's') || (argv[1][2] != '\0'))
  488. X   if (s)
  489. X     (void) puts(s);
  490. X   else
  491. X     (void) puts("not a tty");
  492. X (void) exit(!s);
  493. X}
  494. END_OF_FILE
  495.   if test 298 -ne `wc -c <'util/tty.c'`; then
  496.     echo shar: \"'util/tty.c'\" unpacked with wrong size!
  497.   fi
  498.   # end of 'util/tty.c'
  499. fi
  500. echo shar: End of archive 6 \(of 6\).
  501. cp /dev/null ark6isdone
  502. MISSING=""
  503. for I in 1 2 3 4 5 6 ; do
  504.     if test ! -f ark${I}isdone ; then
  505.     MISSING="${MISSING} ${I}"
  506.     fi
  507. done
  508. if test "${MISSING}" = "" ; then
  509.     echo You have unpacked all 6 archives.
  510.     rm -f ark[1-9]isdone
  511. else
  512.     echo You still must unpack the following archives:
  513.     echo "        " ${MISSING}
  514. fi
  515. exit 0
  516. exit 0 # Just in case...
  517.